﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <meta name="title" content="智慧水控" />

    <title>智慧水控</title>
    <link href="../static/lib/diygw-mobile-all.min.css" rel="stylesheet" />
    <script src="../static/lib/underscore.js"></script>
    <script charset="utf-8" type="text/javascript">
        _.templateSettings = {
            interpolate: /[\$\{]\{(.+?)\}\}?/g,
            evaluate: /<%([\s\S]+?)%>/g
        };
        window.GlobalConfig = {
            loginUrl: '/xcx/login/login.html',
            registerUrl: '/xcx/login/register.html',
            loginCheckUrl: '/xcx/login/loginCheck.html'
        };
        window.STATIC_URL = "";
        window.UEDITOR_SERVER_URL = "/ueditor/index";</script>
    <style type="text/css">
        .top {
            display: none
        }

        .page {
            top: 0;
        }
    </style>
</head>
<body data-ride="animatebox" style="background-color:#ffffff;" data-mpid="36330" data-homepage="" data-dashboardid="36330" data-page_id="72876" data-page_name="智慧水控">
    <div class="container">
        <div class="top">
            <h1 class="page__title" style="background-color:#479de6">智慧水控<span id="PageBack" class="back">返回</span><a class="home fa fa-home ajax-page" id="home" href=".html"></a></h1>
        </div>
        <div class="page" id="page" style="background-color:#ffffff;">
            <div class="pagebg"></div>
            <div class="pagemain">

                <div class="weui-grids bg-blue" id="appmsg805400" style="text-align: center; vertical-align: middle;">
                    <div data-index="8054000" id="datatemplate805400" page="empty" href="#" style="" class="weui-media-box weui-media-box_appmsg    row">
                        <div class="weui-media-box__hd   ">
                            <img alt="智能水控" src="../assets/images/water.png" class="weui-media-box__thumb lazyload" style="" />
                        </div>
                        <div class="weui-media-box__bd">
                            <h4 class="weui-media-box__title" style="">智能水控</h4>
                        </div>
                    </div>
                </div>
                <div class="weui-grids bg-gradual-blue weui-card shadow weui-grids-border" id="appmsg574648" style="font-size: 30px;">
                    <div class="weui-media-box weui-media-box_text row  " style="padding:30px;margin:px;">
                        <div data-index="5746480" id="datatemplate574648" page="empty" href="#">
                            <h4 class="weui-media-box__title" style="">姓名：</h4>
                        </div>
                    </div>
                    <div class="weui-media-box weui-media-box_text row  " style="padding:30px;margin:px;">
                        <div data-index="5746481" page="empty" id="datatemplate574649" href="#">
                            <h4 class="weui-media-box__title" style="">卡内总余额：</h4>
                        </div>
                    </div>
                </div>
                <span id="tmode" style="color:#479de6; text-align:center; font-size:16px;">

                </span>
                <br />
                <span id="wkstate" style="color:red; font-size:16px;">

                </span>
                <br />
                <div class="weui-grids weui-card shadow bg-white" id="warte" style="font-size: 20px; font-family: 雅黑; padding-top: 20px; padding-left: 0px; padding-bottom: 20px;">


                    <!--<a page="empty" data-index="5912530" href="#" style="" class="weui-grid weui-grid-33" id="datatemplate591253">
                        <div style="background-color: #00ff21; " class="weui-grid-inner   weui-card shadow">
                            <div class="weui-grid-inner-content">
                                <p class="weui-grid__label " style="">50 秒</p>
                            </div>
                        </div>
                    </a>
                    <a page="empty" data-index="5912531" href="#" class="weui-grid weui-grid-33">
                        <div style="" class="weui-grid-inner   weui-card shadow">
                            <div class="weui-grid-inner-content">
                                <p class="weui-grid__label " style="">100 秒</p>
                            </div>
                        </div>
                    </a>
                    <a page="empty" data-index="5912532" href="#" class="weui-grid weui-grid-33">
                        <div style="" class="weui-grid-inner   weui-card shadow">
                            <div class="weui-grid-inner-content">
                                <p class="weui-grid__label " style="">200 秒</p>
                            </div>
                        </div>
                    </a>
                    <a page="empty" data-index="5912533" href="#" class="weui-grid weui-grid-33">
                        <div style="" class="weui-grid-inner   weui-card shadow">
                            <div class="weui-grid-inner-content">
                                <p class="weui-grid__label " style="">300 秒</p>
                            </div>
                        </div>
                    </a>
                    <a page="empty" data-index="5912534" href="#" class="weui-grid weui-grid-33">
                        <div style="" class="weui-grid-inner   weui-card shadow">
                            <div class="weui-grid-inner-content">
                                <p class="weui-grid__label " style="">400 秒</p>
                            </div>
                        </div>
                    </a>
                    <a page="empty" data-index="5912535" href="#" class="weui-grid weui-grid-33">
                        <div style="" class="weui-grid-inner   weui-card shadow">
                            <div class="weui-grid-inner-content">
                                <p class="weui-grid__label " style="">500 秒</p>
                            </div>
                        </div>
                    </a>-->

                </div>

                <div class="weui-form" style="padding-top: 50px;">
                    <div class="weui-form-item">
                        <a data-index="2934730" id="btsubmit" href="#" class="weui-btn    bg-blue  ">出 水</a>
                    </div>
                    <div class="weui-form-item">
                        <a data-index="2934730" style="display:none;" id="btntop" href="#" class="weui-btn    bg-blue  ">停止出水</a>
                    </div>
                    <br />
                    <div class="weui-form-item" id="refpath">
                        <a data-index="2934730" href="../index.html" class="weui-btn    bg-blue  ">返回主页</a>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script src="../Script/jquery-1.8.3.min.js"></script>
    <script type="text/javascript">
        var wcmodel = "";
        var price = 0;
        $("#btsubmit").click(function () {
            if (wcmodel == "") {
                alert("当前模式操作繁忙，请重新返回到主页加载打开！");
                return false;
            }
            price = price.replace(" 秒", '');
            price = price.replace(" 毫升", '');
            debugger
            if (price == '') {
                alert('请输入费用！');
                return false;
            }
            var rest = confirm("温馨提示确认出水，确认扣款出水?");
            if (rest == true) {
                var machinenumber = getUrlParam("id");
                var equiment = getUrlParam("jh");
                $.post("../Ajax/Warte.ashx", { funcType: "btsubmit", price: price, machinenumber: machinenumber, equiment: equiment, wcmodelname: wcmodel }, function (data) {
                    if (data == "1") {
                        alert('待出水中....');
                        window.location.href = "WaterControl.html?id=" + machinenumber + "&jh=" + equiment;
                    } else if (data == "-2") {
                        alert('出水失败，请重新扫码！');
                    } else if (data == "-3") {
                        alert('出水失败，卡余额不足！');
                    } else if (data == "-4") {
                        alert('出水失败，非正常卡！');
                    }
                });
            }
        });

        $("#btntop").click(function () {
            var machinenumber = getUrlParam("id");
            var equiment = getUrlParam("jh");
            $.post("../Ajax/Warte.ashx", { funcType: "wkstop", machinenumber: machinenumber, equiment: equiment }, function (data) {
                if (data > 0) {
                    alert("停止成功");
                    $("#btntop").css("display", "none");
                    $("#warte").css("display", "block");
                    $("#btsubmit").css("display", "block");
                } else {
                    alert("停止失败！");
                }

            })
        });


        function getUrlParam(openid) {
            var reg = new RegExp("(^|&)" + openid + "=([^&]*)(&|$)");
            var r = window.location.search.substr(1).match(reg);
            if (r != null) return unescape(r[2]); return null;
        }
    </script>
    <script type="text/javascript">
        $(function () {
            $("#wkstate").html("工作模式:  准备中....");
            $("#warte").css("display", "none");
            $("#btsubmit").css("display", "none");
            var machinenumber = getUrlParam("id");
            var equiment = getUrlParam("jh");
            $.post("../Ajax/InvalidSession.ashx", {}, function (data) {
                if (data == "0") {
                    window.location.replace("../Binding.aspx");
                }
            });
            setInterval(function () {
                $.post("../Ajax/Warte.ashx", { funcType: "workstate", machinenumber: machinenumber, equiment: equiment }, function (data) {
                    var num = data.substr(0, 1);
                    if (num=="-")
                    {
                        num = data.substr(0, 2);
                    }
                    if (num == "-1" || num == "6" || num =="7") {
                        $("#wkstate").html("工作模式:  空闲中");
                        $("#btntop").css("display", "none");
                        $("#warte").css("display", "block");
                        $("#btsubmit").css("display", "block");
                        $("#refpath").css("display", "block");
                    }
                    if (num == "1") {
                        $("#wkstate").html("工作模式:  待出水");
                        $("#btntop").css("display", "block");
                        $("#warte").css("display", "none");
                        $("#btsubmit").css("display", "none");
                        $("#refpath").css("display", "none");
                    }
                    if (num == "2") {
                        $("#wkstate").html("工作模式:  正在出水中..........");
                        $("#btntop").css("display", "block");
                        $("#warte").css("display", "none");
                        $("#btsubmit").css("display", "none");
                        $("#refpath").css("display", "none");
                    }
                    if (num == "3") {
                        $("#wkstate").html("工作模式:  出水完成");
                        $("#btntop").css("display", "none");
                        $("#warte").css("display", "block");
                        $("#btsubmit").css("display", "block");
                        $("#refpath").css("display", "block");

                    }
                    if (num == "4") {
                        $("#wkstate").html("工作模式:  暂停出水");
                    }
                    if (num == "5") {
                        $("#wkstate").html("工作模式:  停止出水");
                        $("#btntop").css("display", "none");
                        $("#warte").css("display", "block");
                        $("#btsubmit").css("display", "block");
                        $("#refpath").css("display", "block");
                    }
                });
            }, 1000);


            $.post("../Ajax/Warte.ashx", { funcType: "UserInfo" }, function (data) {
                debugger
                var dve = $.parseJSON(data);
                var user = JSON.parse(dve.user);
                var tmode = JSON.parse(dve.systemset);
                wcmodel = tmode[0].wcmodel == 0 ? "计时模式" : "计量模式";
                //模式
                $("#datatemplate574648 h4").html("姓名：" + user[0].ryxm);
                $("#datatemplate574649 h4").html("卡内总余额：" + user[0].rfye.toFixed(2));
                if (wcmodel == "计时模式") {
                    $("#tmode").html(wcmodel + " ：时间：" + tmode[0].timing + "（秒） 费率:" + tmode[0].timingmoney + "（分）");
                }

                if (wcmodel == "计量模式") {
                    $("#tmode").html(wcmodel + " ：流量：" + tmode[0].measurement + "（毫升） 费率:" + tmode[0].measurementmoney + "（分）");
                }

                //选择金额
                var str = '';
                if (wcmodel == "计时模式") {
                    debugger
                    for (var i = 0; i < 6; i++) {
                        str = '<a page="empty" data-index="591253' + i + '" href="#" style="" class="weui-grid weui-grid-33" id="datatemplate59125' + i + '">' +
                            '<div id="xz' + i + '" style = "" class="weui-grid-inner   weui-card shadow" >' +
                            '<div class="weui-grid-inner-content">' +
                            '<p class="weui-grid__label " style = "" >' + tmode[0].timing * (i + 1) + ' 秒</p > ' +
                            '</div > ' +
                            '</div > ' +
                            '</a>';
                        $("#warte").append(str);
                    }
                    $("#xz0").css("background-color", "#00ff21");
                }
                if (wcmodel == "计量模式") {
                    debugger
                    for (var i = 0; i < 6; i++) {
                        str = '<a page="empty" data-index="591253' + i + '" href="#" style="" class="weui-grid weui-grid-33" id="datatemplate59125' + i + '">' +
                            '<div id="xz' + i + '" style = "" class="weui-grid-inner   weui-card shadow" >' +
                            '<div class="weui-grid-inner-content">' +
                            '<p class="weui-grid__label " style = "" >' + tmode[0].measurement * (i + 1) + ' 毫升</p > ' +
                            '</div > ' +
                            '</div > ' +
                            '</a>';
                        $("#warte").append(str);
                    }
                    $("#xz0").css("background-color", "#00ff21");
                }

                var thecustom = '<div class="weui-cell" id="thecustom"><div class= "weui-cell__hd"> <label class="weui-label " style="color:red;" for="446714">自定义费用</label></div ><div class="weui-cell__bd"> <input type="text" oninput="value=value.replace(/[^\d]/g,"")" placeholder="" value="" name="name_446714" id="custom" class="weui-input  "> </div></div>';
                $("#warte").append(thecustom)
                price = $("#warte a div p").html();

                $("#thecustom input").click(function () {
                    $("#warte a div").css("background-color", "transparent");
                    price = $(this).html();
                });


                $("#custom").change(function () {
                    price = $(this).val();
                });
                $("#warte a div").on("click", function () {
                    $("#warte a div").css("background-color", "transparent");
                    $("#thecustom div input").val("");
                    $(this).css("background-color", "#00ff21");
                });
                $("#warte a div").on("click", function () {
                    price = $(this).find("p").html();
                });
            })

        });
    </script>
</body>
</html>